package com.xbongbong.saas.enums.business;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.enums.PlatFormEnum;
import com.xbongbong.paas.enums.ScreenTypeEnum;
import com.xbongbong.saas.enums.SetTypeEnum;
import com.xbongbong.saas.enums.ShowTypeEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.base.CommunicateBaseEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 客户跟进记录枚举类
 * 注意：
 * 1.强制：attr的值一经刷入数据库，就不允许改变（比如text_1不允许改为text_12，即使不冲突，因为后续会根据枚举中saasAttr和attr的对应关系来获取解释）
 * 2.强制：属性修饰必须为private，比如private String attr（后续反射获取属性时会依赖到）
 * 3.强制：属性的名称必须和FieldAttrEntity实体中的属性一致，不然无法赋值过
 *
 * @author long.rao
 * @date 2019/1/17 19:35
 */
@Getter
public enum CustomerCommunicateEnum {
    // 跟进记录枚举类型
    // 基本信息
    BASE_INFO(CommunicateBaseEnum.BASE_INFO.getAttr(), "enum.customerCommunicate.attrName.base_info", "baseInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 10000, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    CUSTOMER_NAME(CommunicateBaseEnum.MAIN_BUSINESS.getAttr(), "enum.customerCommunicate.attrName.customer_name", "customerName", FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9990, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    //CUSTOMER_STATUS("text_2", "客户状态", "customerStatus", FieldTypeEnum.COMBO.getType(), 1, 0, 0, ShowTypeEnum.EDIT.getCode(), 9980, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    CONTACT_ARRAY(CommunicateBaseEnum.CONTACT.getAttr(), "enum.customerCommunicate.attrName.contact_array", "contactArray", FieldTypeEnum.LINK_BUSINESS_MULTI.getType(), 3, 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9970, 1, 0, ScreenTypeEnum.SCREEN_SEARCH.getType()),
    TYPE(CommunicateBaseEnum.TYPE.getAttr(), "enum.customerCommunicate.attrName.type", "type", FieldTypeEnum.COMBO.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9960, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    COMMUNICATE_TIME(CommunicateBaseEnum.COMMUNICATE_TIME.getAttr(), "enum.customerCommunicate.attrName.communicate_time", "communicateTime", FieldTypeEnum.DATETIME.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9950, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    COMMUNICATE_BUSINESS(CommunicateBaseEnum.COMMUNICATE_BUSINESS.getAttr(), "enum.customerCommunicate.attrName.communicate_business", "communicateBusiness", FieldTypeEnum.COMBO_LINK_BUSINESS.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9940, 1, 0, ScreenTypeEnum.SCREEN_RELATION.getType()),
    MEMO(CommunicateBaseEnum.MEMO.getAttr(), "enum.customerCommunicate.attrName.memo", "memo", FieldTypeEnum.TEXTAREA.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9930, 1, 1, ScreenTypeEnum.SCREEN_SHOW.getType()),
    VIDEO(CommunicateBaseEnum.VIDEO.getAttr(), "enum.customerCommunicate.attrName.video", "video", FieldTypeEnum.VIDEO.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9920, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    ADDRESS(CommunicateBaseEnum.ADDRESS.getAttr(), "enum.customerCommunicate.attrName.address", "address", FieldTypeEnum.LOCATION.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.ALL.getCode(), 9910, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    IMAGES(CommunicateBaseEnum.IMAGE.getAttr(), "enum.customerCommunicate.attrName.images", "images", FieldTypeEnum.IMAGE.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9900, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    FILE(CommunicateBaseEnum.FILE.getAttr(), "enum.customerCommunicate.attrName.file", "attchment", FieldTypeEnum.UPLOAD.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9890, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    // 关联信息
    ASSOCIATED_INFO(CommunicateBaseEnum.ASSOCIATED_INFO.getAttr(), "enum.customerCommunicate.attrName.associated_info", "associatedInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9880, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    IF_REMIND(CommunicateBaseEnum.IS_REMIND.getAttr(), "enum.customerCommunicate.attrName.if_remind", "ifRemind", FieldTypeEnum.SWITCH.getType(), SetTypeEnum.DISABLE_ALL.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9870, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    NEXT_COMMUNICATE_TIME(CommunicateBaseEnum.NEXT_COMMUNICATE_TIME.getAttr(), "enum.customerCommunicate.attrName.next_communicate_time", "nextCommunicateTime", FieldTypeEnum.DATETIME.getType(), 1, 0, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9860, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),
    NOTIFY_TYPE(CommunicateBaseEnum.NOTIFY_TYPE.getAttr(), "enum.customerCommunicate.attrName.notify_type", "notifyType", FieldTypeEnum.COMBO.getType(), 1, 0, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9850, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),
    NOTIFY_TIME(CommunicateBaseEnum.NOTIFY_TIME.getAttr(), "enum.customerCommunicate.attrName.notify_time", "notifyTime", FieldTypeEnum.DATETIME.getType(), 1, 0, 0, ShowTypeEnum.EDIT.getCode(), 9840, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),
    NEXT_NOTIFY_MEMO(CommunicateBaseEnum.NEXT_NOTIFY_MEMO.getAttr(), "enum.customerCommunicate.attrName.next_notify_memo", "nextNotifyMemo", FieldTypeEnum.TEXTAREA.getType(), 1, 0, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9830, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),
    ENTER_COMMUNICATE_PLAN(CommunicateBaseEnum.ENTER_COMMUNICATE_PLAN.getAttr(), "enum.customerCommunicate.attrName.enter_communicate_plan", "enterCommunicatePlan", FieldTypeEnum.SWITCH.getType(), 1, 0, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9820, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    FINISH_COMMUNICATE_PLAN_ID(CommunicateBaseEnum.FINISH_COMMUNICATE_PLAN_ID.getAttr(), "enum.customerCommunicate.attrName.finish_communicate_plan_id", "finishCommunicatePlanId", FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), 3, 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9810, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    // 系统信息
    SYSTEM_INFO(CommunicateBaseEnum.SYSTEM_INFO.getAttr(), "enum.customerCommunicate.attrName.system_info", "systemInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9800, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    CREATOR_ID(CommunicateBaseEnum.CREATOR_ID.getAttr(), "enum.customerCommunicate.attrName.creator_id", "creatorId", FieldTypeEnum.CREATORID.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9790, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    //    OWNER_ID("ownerId","负责人","addTime",FieldTypeEnum.OWNERID.getType(),1,1,0,ShowTypeEnum.LIST_DETAIL.getCode(),9730,1,0),
    ADD_TIME(CommunicateBaseEnum.ADD_TIME.getAttr(), "enum.customerCommunicate.attrName.add_time", "addTime", FieldTypeEnum.ADDTIME.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9780, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    UPDATE_TIME(CommunicateBaseEnum.UPDATE_TIME.getAttr(), "enum.customerCommunicate.attrName.update_time", "updateTime", FieldTypeEnum.UPDATETIME.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9770, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /*
     OPPORTUNITY_ID("text_8", "机会id", "opportunityId", FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9860, 1, 0, ScreenTypeEnum.SCREEN_ON.getType()),
     CONTRACT_ID("text_9", "合同id", "contractId", FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9850, 1, 0, ScreenTypeEnum.SCREEN_ON.getType()),
     OPPORTUNITY_NAME_LINK_TEXT("text_15", "关联机会隐藏", "opportunityNameLinkText", FieldTypeEnum.TEXT.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9780, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
     CONTRACT_NAME_LINK_TEXT("text_16", "关联合同隐藏", "contractNameLinkText", FieldTypeEnum.TEXT.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9770, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
     */
    // 隐藏逻辑字段
    AUTO_GEN(CommunicateBaseEnum.AUTO_GEN.getAttr(), "enum.customerCommunicate.attrName.auto_gen", "autoGen", FieldTypeEnum.NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9840, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    // TODO 不确定是否要去掉
    USER_ID(CommunicateBaseEnum.USER_ID.getAttr(), "enum.customerCommunicate.attrName.user_id", "userId", FieldTypeEnum.TEXT.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9830, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    USER_NAME(CommunicateBaseEnum.USER_NAME.getAttr(), "enum.customerCommunicate.attrName.user_name", "userName", FieldTypeEnum.TEXT.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9820, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    USER_AVATAR(CommunicateBaseEnum.USER_AVATAR.getAttr(), "enum.customerCommunicate.attrName.user_avatar", "userAvatar", FieldTypeEnum.IMAGE.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9810, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    CUSTOMER_NAME_LINK_TEXT(CommunicateBaseEnum.MAIN_BUSINESS_HIDE.getAttr(), "enum.customerCommunicate.attrName.customer_name_link_text", "customerNameLinkText", FieldTypeEnum.TEXT.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9800, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),
    CONTACT_NAME_LINK_TEXT(CommunicateBaseEnum.CONTACT_HIDE.getAttr(), "enum.customerCommunicate.attrName.contact_name_link_text", "contactNameLinkText", FieldTypeEnum.TEXT.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9790, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    FINISH_COMMUNICATE_PLAN_LINK_TEXT(CommunicateBaseEnum.FINISH_COMMUNICATE_PLAN_LINK_TEXT.getAttr(), "enum.customerCommunicate.attrName.finish_communicate_plan_link_text", "finishCommunicatePlanLinkText", FieldTypeEnum.TEXT.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9760, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    COMMUNICATE_BUSINESS_TYPE(CommunicateBaseEnum.COMMUNICATE_BUSINESS_TYPE.getAttr(), "enum.customerCommunicate.attrName.communicate_business_type", "communicateBusinessType", FieldTypeEnum.NUM.getType(), 3, 1, 1, ShowTypeEnum.NONE.getCode(), 9750, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    COMMUNICATE_BUSINESS_LINK_TEXT(CommunicateBaseEnum.COMMUNICATE_BUSINESS_HIDE.getAttr(), "enum.customerCommunicate.attrName.communicate_business_link_text", "communicateBusinessLinkText", FieldTypeEnum.TEXT.getType(), 3, 1, 1, ShowTypeEnum.NONE.getCode(), 9740, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    AT_USERNAME(CommunicateBaseEnum.AT_USERNAME.getAttr(),"enum.customerCommunicate.attrName.at_username","memoLinkText",FieldTypeEnum.USER_GROUP.getType(),1,0,1,ShowTypeEnum.NONE.getCode(),9730,1,0,ScreenTypeEnum.SCREEN_OFF.getType()),
    ;

    /**
     * 英文名称
     */
    private String attr;
    /**
     * 中文名称
     */
    private String attrName;
    /**
     * 对应saas中的attr
     */
    private String saasAttr;
    /**
     * 字段类型，详见
     *
     * @see com.xbongbong.paas.enums.FieldTypeEnum
     */
    private Integer fieldType;
    /**
     * 重命名、判重、启用必填等权限
     * 1.重命名+字段权限
     * 2.重命名+字段权限+查重
     * 3.重命名+字段权限+启用、必填
     * 4.重命名+字段权限+查重+启用、必填
     * 注：pro中启用和必填是同一个权限，同时启用或同时关闭
     */
    private Integer setType;
    /**
     * 模板设计阶段字段是否允许编辑
     * 1：允许编辑
     * 0：不允许编辑
     */
    private Integer designEditable;
    /**
     * 字段是否显示在模板设计界面
     * 1：不显示
     * 0：显示
     */
    private Integer editHide;
    /**
     * 字段在各个界面（新建、编辑、列表、详情）的展现形式
     * 详见
     *
     * @see com.xbongbong.saas.enums.ShowTypeEnum
     */
    private Integer showType;
    /**
     * 字段在模板设计界面的排序
     * 建议不要用连续的数字，可以用等差数列，以防以后在两个字段之间加入新字段
     */
    private Integer sort;
    /**
     * 字段在各个界面是否可见(启用)
     * 1：可见
     * 0：不可见
     * 注：字段在具体页面的可见性需要用属性和showType联合判断，在visible=1的情况下判断showType
     */
    private Integer visible;
    /**
     * 字段是否必填
     * 1：必填
     * 0：不必填
     */
    private Integer required;
    /**
     * 筛选类型
     * 1：可筛选
     * 2：不可筛选
     */
    private Integer screenType;

    CustomerCommunicateEnum(String attr, String attrName, String saasAttr, Integer fieldType, Integer setType, Integer designEditable,
                            Integer editHide, Integer showType, Integer sort, Integer visible, Integer required, Integer screenType) {
        this.attr = attr;
        this.attrName = attrName;
        this.saasAttr = saasAttr;
        this.fieldType = fieldType;
        this.setType = setType;
        this.designEditable = designEditable;
        this.editHide = editHide;
        this.showType = showType;
        this.sort = sort;
        this.visible = visible;
        this.required = required;
        this.screenType = screenType;
    }

    /**
     * 对data内的字段拼上“data.”
     *
     * @param cache
     * @return java.lang.String
     * @author zcp
     * @date 2019/3/1 18:12
     * @version v1.0
     * @since v1.0
     */
    public static String getAttrConnectData(CustomerCommunicateEnum cache) {
        return "data." + cache.getAttr();
    }

    /**
     * 获取es查询、聚合字段
     * data在库内是json对象，对data字段内某个key做es【精确查询】时，需要在其前拼上“data.”，且【text等类型的】要在后面拼“.keyword”
     *
     * @param cache 当前枚举对象
     * @return java.lang.String 处理后的聚合字段
     * @author zcp
     * @date 2019/2/21 14:59
     * @version v1.0
     * @since v1.0
     */
    public static String getEsAttr4Keyword(CustomerCommunicateEnum cache) {
        FieldTypeEnum fieldTypeEnum = FieldTypeEnum.getFieldTypeEnum(cache.fieldType);
        //字段类型为text，或者字段在es内的类型时text，则需要在后面拼上“.keyword”
        boolean flag = fieldTypeEnum == FieldTypeEnum.TEXT || "text".equals(fieldTypeEnum.getEsalias());
        if (flag) {
            return "data." + cache.getAttr() + ".keyword";
        }
        return "data." + cache.getAttr();
    }

    public static CustomerCommunicateEnum getByAttr(String attr) {
        for (CustomerCommunicateEnum customerCommunicateEnum : values()) {
            if (Objects.equals(customerCommunicateEnum.getAttr(), attr)) {
                return customerCommunicateEnum;
            }
        }
        return null;
    }

    /**
     * 跟进记录过滤字段
     *
     * @param subBusinessType
     * @return
     */
    private static List<String> detailFilterBySubBusinessType(Integer subBusinessType) {
        XbbRefTypeEnum xbbRefTypeEnum = XbbRefTypeEnum.getByCode(subBusinessType);
        switch (xbbRefTypeEnum) {
            case DETAIL_CUSTOMER_COMMUNICATE:
                return new ArrayList<>();
            case DETAIL_CONTRACT_COMMUNICATE:
                return Arrays.asList(COMMUNICATE_BUSINESS.getAttr());
            case DETAIL_OPPORTUNITY_COMMUNICATE:
                return Arrays.asList(COMMUNICATE_BUSINESS.getAttr());
            case DETAIL_QUOTATION_COMUNICATE:
                return Arrays.asList(COMMUNICATE_BUSINESS.getAttr());
            case DETAIL_CONTACT_COMMUNICATE:
                return Arrays.asList(CONTACT_ARRAY.getAttr());
            case DETAIL_CLUE_COMUNICATE:
                List<String> attrs = new ArrayList<>(getCommunicateRemoveAttrs4Clue());
                attrs.add(COMMUNICATE_BUSINESS.getAttr());
                return attrs;
            default:
                break;
        }
        return new ArrayList<>();
    }

    /**
     * 跟进记录保留字段
     *
     * @param subBusinessType
     * @return
     */
    private static List<String> detailRetainBySubBusinessType(Integer subBusinessType) {
        XbbRefTypeEnum xbbRefTypeEnum = XbbRefTypeEnum.getByCode(subBusinessType);
        switch (xbbRefTypeEnum) {
            case DETAIL_CUSTOMER_COMMUNICATE:
                return Arrays.asList(COMMUNICATE_BUSINESS.getAttr(), CONTACT_ARRAY.getAttr(), IMAGES.getAttr(), FILE.getAttr(), MEMO.getAttr());
            case DETAIL_CONTRACT_COMMUNICATE:
                return Arrays.asList(CONTACT_ARRAY.getAttr(), IMAGES.getAttr(), FILE.getAttr(), MEMO.getAttr());
            case DETAIL_OPPORTUNITY_COMMUNICATE:
                return Arrays.asList(CONTACT_ARRAY.getAttr(), IMAGES.getAttr(), FILE.getAttr(), MEMO.getAttr());
            case DETAIL_QUOTATION_COMUNICATE:
                return Arrays.asList(CONTACT_ARRAY.getAttr(), IMAGES.getAttr(), FILE.getAttr(), MEMO.getAttr());
            case DETAIL_CONTACT_COMMUNICATE:
                return Arrays.asList(COMMUNICATE_BUSINESS.getAttr(), IMAGES.getAttr(), FILE.getAttr(), MEMO.getAttr());
            case DETAIL_CLUE_COMUNICATE:
                return Arrays.asList(IMAGES.getAttr(), FILE.getAttr(), MEMO.getAttr());
            default:
                break;
        }
        return new ArrayList<>();
    }

    /**
     * 线索关联新建或编辑跟进记录时去除掉以下字段
     */
    public static List<String> getCommunicateRemoveAttrs4Clue() {
        List<String> attrs = Arrays.asList(CUSTOMER_NAME.getAttr(), CONTACT_ARRAY.getAttr(), IF_REMIND.getAttr(), NEXT_COMMUNICATE_TIME.getAttr(),
                NOTIFY_TYPE.getAttr(), NOTIFY_TIME.getAttr(), NEXT_NOTIFY_MEMO.getAttr(), ENTER_COMMUNICATE_PLAN.getAttr(), FINISH_COMMUNICATE_PLAN_ID.getAttr());
        return attrs;
    }

    /**
     * 线索关联新建时需要去除的字段
     * @param platform: 平台标识
     * @return
     */
    public static List<String> getCommunicateRemoveAttrs4ClueLinkAdd(String platform) {
        if(Objects.equals(platform, PlatFormEnum.WEB.getValue())){
            return Arrays.asList(CUSTOMER_NAME.getAttr(), CONTACT_ARRAY.getAttr(), ENTER_COMMUNICATE_PLAN.getAttr(), FINISH_COMMUNICATE_PLAN_ID.getAttr());
        }else {
            return Arrays.asList(CUSTOMER_NAME.getAttr(), CONTACT_ARRAY.getAttr(), NOTIFY_TIME.getAttr(), ENTER_COMMUNICATE_PLAN.getAttr(), FINISH_COMMUNICATE_PLAN_ID.getAttr());
        }
    }


    /**
     * 是否是需要过滤删除的字段
     *
     * @param attr
     * @param subBusinessType
     * @param required
     * @param fieldType
     * @return
     */
    public static Boolean detailFilter(String attr, Integer subBusinessType, Integer required, Integer fieldType) {
        //客户直接过滤
        if (Objects.equals(CUSTOMER_NAME.getAttr(), attr)) {
            return true;
        }
        //过滤本业务
        if (detailFilterBySubBusinessType(subBusinessType).contains(attr)) {
            return true;
        }
        //强制保留
        if (detailRetainBySubBusinessType(subBusinessType).contains(attr)) {
            return false;
        }
        if (Objects.equals(fieldType, FieldTypeEnum.SEPARATOR.getType())) {
            return true;
        }
        //过滤非必填
        return Objects.equals(required, 0);
    }

    /**
     * 把传入的字段（类型为LINK_BUSINESS_SINGLE）的转为其隐藏字段
     * @param attr 字段名
     * @return java.lang.String
     * @author zcp
     * @date 2019/7/4 15:31
     * @since v1.0
     * @version v1.0
     */
    public static String changeToHide4Link(String attr) {
        if (Objects.equals(attr, CUSTOMER_NAME.attr)) {
            return CUSTOMER_NAME_LINK_TEXT.attr;
        } else if (Objects.equals(attr, FINISH_COMMUNICATE_PLAN_ID.attr)) {
            return FINISH_COMMUNICATE_PLAN_LINK_TEXT.attr;
        } else if (Objects.equals(attr, COMMUNICATE_BUSINESS.attr)) {
            return COMMUNICATE_BUSINESS_LINK_TEXT.attr;
        } else if (Objects.equals(attr, CONTACT_ARRAY.attr)) {
            return CONTACT_NAME_LINK_TEXT.attr;
        }
        return attr;
    }

    public String getAttrName() {
        return I18nMessageUtil.getMessage(attrName);
    }

    public static String getI18nValue(String value) {
        return I18nMessageUtil.getMessage(value);
    }
}
